/*
  Copyright (c) 2009-10 by kRaw1er & HierOS
  This file is part of M8J project
*/
#include <ceconfig.h>
#include "CM8JMainWnd.h"
#include <ReadWriteIni.h>
#include "defs.h"
#include "utils\utils.h"

class CM8JApp : public CMzApp
{
public:
	CM8JMainWnd m_MainWnd;

	virtual BOOL Init()
	{
		CoInitializeEx(NULL, COINIT_MULTITHREADED);

		LoadLang(LANG_RU);
		LoadGraphics();

		DWORD dwFirstRun;
		RegReadDWORD(HKEY_CURRENT_USER,L"Software\\HierOS\\M8Jabber\\",L"FirstRun",dwFirstRun);
		if (dwFirstRun != 1)
		{
		RegWriteDWORD(HKEY_CURRENT_USER,L"Software\\HierOS\\M8Jabber\\",L"FirstRun",1,true);
		IniCreateFile(accIniFile());
		IniWriteString(APP_NAME, L"Username", L"", accIniFile());
		IniWriteString(APP_NAME, L"Password", L"", accIniFile());
		IniWriteString(APP_NAME, L"Server", L"", accIniFile());
		IniWriteString(APP_NAME, L"Resource", L"Meizu-M8", accIniFile());
		IniWriteString(APP_NAME, L"Port", L"5222", accIniFile());
		IniCreateFile(optIniFile());
		IniWriteString(APP_NAME, L"EnableSound", L"1", optIniFile());
		IniWriteString(APP_NAME, L"EnableVibration", L"1", optIniFile());
		IniWriteString(APP_NAME, L"ShowOffline", L"1", optIniFile());
		}

		RECT rc = MzGetWorkArea();
		m_MainWnd.Create(rc.left, rc.top, RECT_WIDTH(rc), RECT_HEIGHT(rc), 0, 0, 0);
		if ( MzGetParam(MZGP_APP_START_ANIMATION)==TRUE )   
		{
			m_MainWnd.AnimateWindow( MZ_ANIMTYPE_ZOOM_IN , true);
			m_MainWnd.Show();
		}

		return TRUE;
	}

};

CM8JApp theApp;